package com.zy.service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.zy.mapper.SupperMapper;
import com.zy.pojo.Supper;
import com.zy.service.SupperService;
import com.zy.vo.Supper.PageSto;
import com.zy.vo.Supper.SupperVo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service("supperService")
public class SupperServiceImpl extends ServiceImpl<SupperMapper, Supper> implements SupperService {
    @Resource
    private SupperMapper supperMapper;


    @Override
    public List<Supper> getSupperList() {
         return supperMapper.selectList(null);
    }

    @Override
    public PageSto getPage(Integer pageNo, Integer pageSize, SupperVo supperVo) {
        Page page = new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(supperVo.getSupperName()),"supper_Name",supperVo.getSupperName())
                .like(!StringUtils.isEmpty(supperVo.getSupperUsername()),"supper_Username",supperVo.getSupperUsername());
        List<Supper> list = supperMapper.getSupperList(page,queryWrapper);
        System.out.println(page.getTotal()+"+++++++++++++++++++++++++");
        return new PageSto(list,page.getTotal());
    }

    @Override
    public void getsupperadd(Supper supper) {

        supperMapper.insert(supper);
    }

    @Override
    public void getsupperdel(Integer id) {
        supperMapper.deleteById(id);
    }

    @Override
    public void getsupperupdate( Supper supper) {
        supperMapper.updateById(supper);

    }


}
